package com.example.pair;

import org.apache.commons.lang3.tuple.ImmutableTriple;
import org.apache.commons.lang3.tuple.MutableTriple;

public class TestTriple {

    /**
     * MutableTriple 返回值可变
     *
     * @param user
     * @return
     */
    private static MutableTriple<String, String, User> processUserInfo(User user) {
        return MutableTriple.of(user.getId(), user.getName(), user);
    }

    /**
     * ImmutableTriple 返回值不可变
     *
     * @param user
     * @return
     */
    private static ImmutableTriple<String, String, User> processUserInfo1(User user) {
        return ImmutableTriple.of(user.getId(), user.getName(), user);
    }

    public static void main(String[] args) {
        User user = new User();
        user.setId("userId");
        user.setName("张三");

        MutableTriple<String, String, User> mutableTriple = processUserInfo(user);
        System.out.println(mutableTriple);
        mutableTriple.setMiddle("李四");
        System.out.println(mutableTriple);
        System.out.println("----------------------------------");
        ImmutableTriple<String, String, User> immutableTriple = processUserInfo1(user);
        System.out.println(immutableTriple);
    }
}
